using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;

namespace Lzfy_His_Service.Models
{
    public class User
    {
        public int Id { get; set; }
        public string Username { get; set; } = string.Empty;
        
        [Column("password_hash")]
        public string PasswordHash { get; set; } = string.Empty;
        
        public string? Email { get; set; }
        
        [Column("full_name")]
        public string? FullName { get; set; }
        
        public string Role { get; set; } = "User";
        
        [Column("is_active")]
        public bool IsActive { get; set; } = true;
        
        [Column("created_at")]
        public DateTime CreatedAt { get; set; }
        
        [Column("updated_at")]
        public DateTime UpdatedAt { get; set; }
        
        [Column("last_login_at")]
        public DateTime? LastLoginAt { get; set; }
    }

    public class LoginRequest
    {
        public string Username { get; set; } = string.Empty;
        public string Password { get; set; } = string.Empty;
        public string Captcha { get; set; } = string.Empty;
    }

    public class LoginResponse
    {
        public string Token { get; set; } = string.Empty;
        public int Id { get; set; }
        public string Username { get; set; } = string.Empty;
        public string? FullName { get; set; }
        public string Role { get; set; } = string.Empty;
        
        [JsonPropertyName("userPhone")]
        public string UserPhone { get; set; } = string.Empty;
        
        public DateTime ExpiresAt { get; set; }
    }
}